package com.cloudfun.campusshare.configuration.property;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author : zhangyongjie
 * @version : 1.0
 * @createTime : 2021/2/4 15:27
 * @description :
 */
@Data
@Component
@ConfigurationProperties(prefix = "hsq")
public class HsqProperty implements InitializingBean {

    /**
     * 慧收钱网关
     */
    private String gateway;

    /**
     * 回调地址
     */
    private String callback;

    /**
     * 商户号
     */
    private String merchantId;

    /**
     * 慧收钱解密公钥
     */
    private String publicKeyPath;

    /**
     * 私钥路径
     */
    private String privateKeyPath;
    /**
     * 证书密码
     */
    private String password;

    /**
     * 商户进件网关
     */
    private String registerGateway;

    @Override
    public void afterPropertiesSet() throws Exception {
        if(StringUtils.isBlank(gateway) || StringUtils.isBlank(callback) || StringUtils.isBlank(merchantId)){
            throw new RuntimeException("慧收钱配置不正确");
        }
    }
}
